package com.kabigon.tiny.log;

import com.kabigon.tiny.log.aspect.SysLogAspect;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * 日志自动配置
 * <p>
 *     启动条件：
 *     1. 存在web环境
 *     2. 配置文件中 kabigon.log.enbale=true
 *     3. 配置文件中不存在 kabigon.log.enbale
 * </p>
 * @author xu.biao
 * @version v1.0
 */
@EnableAsync
@Configuration
@ConditionalOnWebApplication
@ConditionalOnProperty(name = "spring.log.enable", havingValue = "true", matchIfMissing = true)
public class LogAutoConfiguration {
    @Bean
    @ConditionalOnMissingBean
    public SysLogAspect sysLogAspect() {
        return new SysLogAspect();
    }
}
